<!--
wy 购物车页面
描述：显示购物车
最后修改时间：9.16/16:19
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>吃游网-购物车</title>

    <link rel="stylesheet" href="css/quote/bootstrap.css">
    <link rel="stylesheet" href="css/head.css">
    <link rel="stylesheet" href="css/footer.css">
    <link rel="stylesheet" href="css/home/home.css">
    <link rel="stylesheet" href="css/shopcart.css">

    <script src="js/quote/jquery-3.4.1.js"></script>
    <script src="js/quote/hf.js"></script>
    <script src="js/quote/jquery.js"></script>
    <script src="js/quote/bootstrap.js"></script>
    <script src="js/custom.js"></script>
    <link rel="stylesheet" href="css/layui.css">
</head>
<body>
<div class="page-content background body">

    <div class="container">
        <div class="">
            <h3 style="margin: 22px 0">订单详情 </h3>
        </div>
    </div>

    <div class="cart-warp background">
        <div class="w">
            <div id="jd-cart" style="margin-left: -75px;margin-right:  -55px">
                <div class="cart-main cart-main-new">
                    <div class="cart-thead">
                        <div class="column t-checkbox" style="margin-left: 10px">美食图片</div>
                        <div class="column t-goods" style="text-align: center">商品</div>
                        <div class="column t-props">商家</div>
                        <div class="column t-price" style="margin-left: 10px">单价</div>
                        <div class="column t-quantity" style="margin-left: 10px">数量</div>
                        <div class="column t-sum" style="margin-left: -20px">小计</div>
                        <div class="column t-action" style="margin-left: 30px">商品评分</div>

                    </div>
                    <div id="cart-list">
                        <!-- 需要引用的全局信息 -->
                        <div class="cart-item-list" id="cart-item-list-01">
                            <div class="cart-tbody" id="vender_8888">

                                <div class="item-list">

                                    <div class="item-full " id="product_promo_50036182740">





                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>


                <div id="cart-floatbar">
                    <div class="ui-ceilinglamp-1" style="width: 990px; height: 52px;">
                        <div class="cart-toolbar" style="width: 1120px; height: 50px;">
                            <div class="toolbar-wrap">

                                <div class="options-box" style="left: -60px">


                                    <div class="toolbar-right toolbar-right-new">
                                        <div class="normal">
                                            <div class="comm-right">

                                                <div class="btn-area" >
                                                    <!--      <a  href="/alipay/payInfo?money=" class="submit-btn" onclick="subm()">立即支付</a>-->
                                                    <button class="submit-btn" onclick="subm()">提交评分</button>
                                                </div>
                                          <!--      <div class="price-sum">
                                                    <div>
                                                        <span class="txt txt-new">总价：</span>
                                                        <span class="price sumPrice"></span>
                                                    </div>
                                                </div>-->

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>


<script>


    function getQueryVariable(variable) {
        let query = window.location.search.substring(1);
        let vars = query.split("&");
        for (let i = 0; i < vars.length; i++) {
            let pair = vars[i].split("=");
            if (pair[0] == variable) {
                return pair[1];
            }
        }
        return (false);
    }


    /*var search = location.search;

    var orderId = search.split("=")[1];*/

    var orderIsPay=getQueryVariable("orderIsPay")

    var aa

    var arr=new Array()
    $.ajax({
        url:"commodity/findCommodityByOrderId1",
        data:{"orderId":getQueryVariable("orderId")},
        async:false,
        success:function (data) {
            console.log(data)

            var html=''
            var total = 0.00;
            var storeName='';
            $.each(data,function (index,dom) {

                total = total + (dom.commodityPrice)*(dom.commodityNumber).toFixed(2)
                storeName=dom.store.storeName
                html+='  <div class="  item-last  item-item ">\n' +
                    '                                            <div class="item-form">\n' +
                    '                                                <div class="cell p-goods">\n' +
                    '                                                    <div class="goods-item">\n' +
                    '                                                        <div class="p-img" style="margin-left: -30px">\n' +
                    '                                                            <a href="commodity.html?commodityId='+dom.commodityId+'"><img\n' +
                    '                                                                    src="'+dom.pictureList[0].picture+'" style="width:80px;height:80px"></a>\n' +
                    '                                                        </div>\n' +
                    '                                                        <div class="p-name" style="margin-left: 170px">\n' +
                    '                                                            <a href="commodity.html?commodityId='+dom.commodityId+'">'+dom.commodityName+' </a>\n' +
                    '                                                        </div>\n' +
                    '                                                    </div>\n' +
                    '                                                </div>\n' +
                    '                                                <div class="cell p-props p-props-new">\n' +
                    '                                                    <div class="props-txt" style="margin-left: -20px">'+dom.store.storeName+'</div>\n' +
                    '                                                </div>\n' +
                    '                                                <div class="cell p-price p-price-new">\n' +
                    '                                                    <p class="plus-switch">\n' +
                    '                                                        <strong>¥'+dom.commodityPrice.toFixed(2)+'</strong>\n' +
                    '                                                    </p>\n' +
                    '                                                </div>\n' +
                    '                                                <div class="cell p-quantity" style="text-align: center">\n' +
                    '                                                    <span>'+dom.commodityNumber+'</span>\n' +
                    '                                                </div>\n' +
                    '                                                <div class="cell p-sum">\n' +
                    '                                                    <strong>¥'+(dom.commodityPrice*dom.commodityNumber).toFixed(2)+'</strong>\n' +
                    '\n' +
                    '                                                </div>\n' +
                    '\n' +
                    '                                                <div class="cell p-ops" style="width: 250px">\n' +
                    '                                                    <div class="input-group" style="width: 160px">\n' +
                    '      <input type="text" class="form-control" placeholder="请输入您的评分"style="width: 130px">\n' +
                    '      <span class="input-group-btn">\n' +
                    '        <button class="btn btn-default" type="button" style="float:left;">分</button>\n' +
                    '      </span>\n' +
                    '    </div><!-- /input-group -->\n' +
                    '                                                </div>\n' +
                    '                                            </div>\n' +
                    '                                        </div>'



            })

            $(".item-full").html(html)



        }

    })





</script>


<script>

    var arr2=new Array()
    var arr=new Array()
    function subm() {

        var count=1;

        $(".form-control").each(function () {
            if($(this).val()==null||$(this).val()==""){
                count=2
                $(this).val("")
                $(this).attr("placeholder","请输入评分！！！")
            }



            if(parseFloat($(this).val())>10||parseFloat($(this).val())<0){

                $(this).val("")
                $(this).attr("placeholder","评分需在0-10分")

                             count=0

            }
            arr2.push( $(this).val())


        })

        if(count==1){

          $.ajax({
              url:"commodity/findCommodityByOrderId1",
              data:{"orderId":getQueryVariable("orderId")},
              async:false,
              success:function (data) {
                  $.each(data,function (index,dom) {

                      arr.push( dom.commodityId)

                  })

                  $.ajax({

                      url: "/commodity/updataComm",

                     /* dataType:'json',
                      contentType: "application/json",*/

                   /*   data:{"commodityIds":arr,"commGrade":arr2},*/
                      data:"commodityIds=" + arr + '&commGrade=' + arr2,
/*                      data:{"commodityIds":arr},*/
                      success: function (data) {
                         console.log("AAAAAAAAAAAAAAAAAAAAAAAAAAA")
                          console.log(data)
                      }
                  })

              }


          })
            $(".submit-btn").css("background-color","#808080")
            $(".submit-btn").html("已评分")
            $(".submit-btn").removeAttr("onclick");
            alert("评分成功")
        }





    }

</script>
</html>